var price=0;
var total_price = document.getElementById('money'); //总价
var number = document.getElementById('number'); //人数
var count =0;//记录乘机人数
var div0 = document.getElementById("div-0");
var cjr=document.getElementById("cjr")

function Delete(){
	//获取本删除按钮的id值，并创建对象
	/*var st=obj.id;//得到id=delete
	var o=document.getElementById(st);
	var z=o.parentElement;//父元素id="n_pass"
	//找到这个删除按钮对应的父div的值
    var s=z.id;
    var str=s.parentElement;
    var father=str.id;*/
	//判断本id对应的值并删除
    my = document.getElementById("div-"+count);
    if (my != null){
    my.parentNode.removeChild(my);}
    
    //div0.parentNode.removeChild(document.getElementById("div-"+count));
}

function Check(){
    if(count!=0){
        var clonedNode = div0.cloneNode(true); // 克隆节点 
        clonedNode.setAttribute("id", "div-" + count); // 修改一下id 值，避免id 重复 
        div0.parentNode.appendChild(clonedNode); // 在父节点插入克隆的节点
        document.getElementById("div-"+count).style.cssText= "position: relative;top: 10px;left: 55px;width: 820px;height: 240px;border: 1px solid #C0C0C0";//设置css
    }
}

function Select_passage(v,s){
    var npass=document.getElementById("one_pass");//第n位乘机人位置那
    var passager_name=document.getElementById("p_name");//获取乘机人姓名
    if(v.checked){//被点击
        Check();
        passager_name.value=s;
        npass.innerHTML=s;
        count+=1;
        number.innerHTML=count;
        price+=1100;
        total_price.innerHTML=price;
        cjr.innerHTML=count;
    }
    else{
        passager_name.value="";
         npass.innerHTML=null;
        count-=1;
        number.innerHTML=count;
        price-=1100;
        total_price.innerHTML=price;
        cjr.innerHTML=count;
        //Delete();
        //div0.parentNode.removeChild(document.getElementById("div-"+count));
    }
}

/*
function Select_passage(v,s){
    //var div = document.getElementById("divBox");
    var npass=document.getElementById("one_pass");
    var passager_name=document.getElementById("p_name");//获取乘机人姓名
    if(count)   
    {
        if(v.checked){//被点击
            passager_name.value=s;
            npass.innerHTML=s;
            count+=1;
        }
        else{
            div_0.removeChild(document.getElementById("div-"+0));
            /*passager_name.value="";
            npass.innerHTML=null;
            count-=1;
        }
    }
    else{
        var div = document.getElementById("add_pass");//增加乘客节点
        var div_0 =document.getElementById("div-0");
        var clonedNode = div_0.cloneNode(true); // 克隆节点 
        clonedNode.setAttribute("id", "div-" + count); // 修改一下id 值，避免id 重复 
        div.parentNode.insertBefore(clonedNode); // 在父节点插入克隆的节点
        if(v.checked){//被点击
            passager_name.value=s;
            npass.innerHTML=s;
            count++;
        }
        else{
            div_0.removeChild(document.getElementById("div-"+count));
        }
    }
}*/